package com.ocom.common.utils;

import com.ocom.common.enums.ResultEnum;
import com.ocom.common.resp.Result;


/**
 * 服务公共实体
 */
public class ResultUtil {

    public static Result success(Object objects) {
        Result result = new Result(ResultEnum.Success_Success, objects);
        return result;
    }

    public static Result success() {
        return success(null);
    }

    public static Result error(ResultEnum resultEnum) {
        Result result = new Result(resultEnum);
        return result;
    }

    public static Result error(ResultEnum resultEnum,Object object) {
        Result result = new Result(resultEnum,object);
        return result;
    }

    public static Result error(Integer code) {
        Result result = new Result();
        result.setCode(code);
        String msg=ResultEnum.getValueByKey(code);
        result.setMsg(msg);
        return result;
    }


    public static Result info(Integer code,String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static Result info(Integer code,String msg,Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }
    public static Result success(Integer code,String msg,Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }


}
